import store from "@/store";
// btnPermiss.js
export default {
  bind(ele, bindings) {
    //ele：为绑定的元素标签    bindings：绑定相关的信息
    let permissions = [];
    const role = store.getters && store.getters.menu;
    role.map((item, index) => {
      if (item.meta) {
        item.children.map((i) => {
          if (i.btns.length > 0) {
            i.btns.map((it) => {
              permissions.push(it.menuPermission);
            });
          }
        });
      }
    });
    permissions.filter((item) => {
      const hasPemission = permissions.includes(bindings.value);
      if (!hasPemission) {
        setTimeout(() => {
          ele.parentNode &&  ele.parentNode.removeChild(ele);
        }, 0);
      }
    });
  },
};
